/*
Compare Version Numbers

Compare two version numbers version1 and version2.
If version1 > version2 return 1, if version1 < version2 return -1, otherwise return 0.

You may assume that the version strings are non-empty and contain only digits and the . character.
The . character does not represent a decimal point and is used to separate number sequences.
For instance, 2.5 is not "two and a half" or "half way to version three", it is the fifth second-level revision of the second first-level revision.

Here is an example of version numbers ordering:

0.1 < 1.1 < 1.2 < 13.37

*/

#include <iostream>
#include <vector>
#include <map>
#include <algorithm>
#include <string>
#include <stack>
#include <queue>
#include <fstream>
#include <sstream>
#include <unordered_set>
#include "print.h"
using namespace std;

/**
* Definition for binary tree*/
typedef __int32 uint32_t;


void testForStack()
{
	stack<int> mystack;
	mystack.push(10);
	mystack.push(20);
	mystack.top() -= 5;
	cout << "mystack.top() is now " << mystack.top() << endl;
}

void testForIntToString()
{
	int a = 10;
	stringstream ss;
	ss << a;
	string str = ss.str();
	cout << str << endl;

	string str1 = to_string(a);

}


class Solution {
public:
	int compareVersion(string version1, string version2) {
		int val1, val2;
		int idx1 = 0, idx2 = 0;
		while (idx1 < version1.length() || idx2 < version2.length()) {
			val1 = 0;
			while (idx1 < version1.length()) {
				if (version1[idx1] == '.') {
					++idx1;
					break;
				}
				val1 = val1 * 10 + (version1[idx1] - '0');
				++idx1;
			}
			val2 = 0;
			while (idx2 < version2.length()) {
				if (version2[idx2] == '.') {
					++idx2;
					break;
				}
				val2 = val2 * 10 + (version2[idx2] - '0');
				++idx2;
			}
			if (val1 > val2) return 1;
			if (val1 < val2) return -1;
		}
		return 0;
	}
};



int main(int argc, char* argv[])
{


	int a = 0;

	for (int i = 1; i < argc; i++){


		cout << argv[i] << endl;
		a = atoi(argv[i]);
	}


	double f = 19;



	Solution s;
	//stackTree.push(p->left);
	//stackTree.push(p->right);

	ListNode *headA = new ListNode(1);
	ListNode *pa1 = new ListNode(2);
	ListNode *pa2 = new ListNode(3);
	headA->next = pa1;
	pa1->next = pa2;

	ListNode *headB = new ListNode(4);
	//ListNode *pa1 = new ListNode(2);
	//ListNode *pa2 = new ListNode(3);
	//headA->next = pa1;
	//pa1->next = pa2;
	ListNode *result = new ListNode(-1);
	result = s.getIntersectionNode(headA, headB);
	system("pause");
	return 0;
}